package com.hskn.hss.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.hskn.hss.module.button.entity.SysButton;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

@Data
public class MenuTreeEntity {
    private String id;
    private String name;
    private String parentid;
    private String type;

    private String parentname;
    private String applabel;
    private String action;
    private String status;
    private List<SysButton> sysbutton;
    /**
     * 1:菜单，2：按钮
     */
    private Integer subjectType = 1;
    private List<MenuTreeEntity> children;

    public MenuTreeEntity() {
    }

    public MenuTreeEntity(SysButton sysButton) {
        this.id = sysButton.getId();
        this.name = sysButton.getName();
        this.parentid = sysButton.getMenuid();
        this.type = sysButton.getType();
        this.applabel = sysButton.getLabel();
        this.action = sysButton.getAction();
        this.status = sysButton.getStatus();
        this.subjectType = 2;
    }
    public static List<MenuTreeEntity> buildMenuTreeEntityList(List<SysButton> sysButtonList) {
        List<MenuTreeEntity> menuTreeEntityList = new ArrayList<>();
        if (CollectionUtils.isNotEmpty(sysButtonList)) {
            for (SysButton sysButton : sysButtonList) {
                menuTreeEntityList.add(new MenuTreeEntity(sysButton));
            }
        }
        return menuTreeEntityList;
    }
}
